import axios from '../index';

const USRE_INFO_URL = '/passports/detail';
const USER_INFO_MODIFY_URL = '/passports/update';
const MODIFY_PASSWORD_URL = '/passports/changePassword';
const GET_ACCOUNTS = '/passports/query'; // 分页查询账户
const LOAD_DEPT = '/enterprise/company/department/list' // 部门列表
const DELETE_ACCOUNT = '/passports/delete' // 删除账户

async function getUserInfo () {
  const response = await axios.get(USRE_INFO_URL);
  return response;
}

async function modifyAccount (params) {
  const response = await axios.post(USER_INFO_MODIFY_URL, params);
  console.log(response)
  return response;
}

async function modifyPassword (oldPassword, newPassword) {
  const response = await axios.post(MODIFY_PASSWORD_URL, { oldPassword, newPassword });
  return response;
}

async function getAccounts (params) {
  const response = await axios.post(GET_ACCOUNTS, params);
  return response;
}

async function loadDept (params) {
  const response = await axios.post(LOAD_DEPT, params);
  return response;
}

async function deleteAccount (params) {
  const response = await axios.post(DELETE_ACCOUNT, params);
  return response;
}

export default {
  getUserInfo,
  modifyAccount,
  modifyPassword,
  getAccounts,
  loadDept,
  deleteAccount
};
